package cn.ejiajunxy.manager.common;

import com.allen.library.observer.CommonObserver;

import cn.ejiajunxy.manager.LoginActivity;
import cn.ejiajunxy.manager.app.CustomApplication;
import cn.ejiajunxy.manager.model.BaseModel;

/**
 * Created by zhangguobao on 2018/2/26.
 */

public abstract class AppObserver<T> extends CommonObserver<T> {

    @Override
    protected void onSuccess(T t) {
        if (t instanceof BaseModel) {
            if (((BaseModel) t).error_code == 10105) {
                LoginActivity.start(CustomApplication.getAppContext(), LoginActivity.sTYPE_TOKEN);
            } else {
                success(t);
            }
        } else {
            success(t);
        }
    }

    protected abstract void success(T t);
}
